package com.huike.web.controller.clues;

import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.dto.TbClueDTO;
import com.huike.clues.domain.vo.TbClueVo;
import com.huike.clues.service.TbClueService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 线索管理Controller
 *
 * @date 2023-04-02
 */
@Slf4j
@Api(tags = "线索管理相关接口")
@RestController
@RequestMapping("/clues/clue")
public class TbClueController extends BaseController {

    @Autowired
    private TbClueService clueService;


    /**
     * 新增线索管理
     */
    @PostMapping
    @ApiOperation("新增线索管理")
    public AjaxResult add(@RequestBody TbClueDTO dto){
        log.info("新增线索管理--前端传来的参数为{}",dto);
        clueService.add(dto);
        return AjaxResult.success();
    }


    /**
     * 分页查询
     */
    @GetMapping("/list")
    @ApiOperation("分页查询")
    public TableDataInfo list(TbClueDTO dto){
        log.info("分页查询--前端传来的参数为{}",dto);
        startPage();
        List<TbClueVo> clueList = clueService.pageList(dto);
        return getDataTable(clueList);
    }
}
